package jingdong;

import java.util.*;
import java.util.Scanner;

/**
 * Created by lxy_920912 on 07/04/2017.
 */
public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] prise = new int[m];

        for(int i = 0;i < m;i++){
            prise[i] = scanner.nextInt();
        }
        Arrays.sort(prise);
        if(n == 0){
            System.out.println(0);
            return;
        }
        int max = prise[0];
        int sum = 0;
        sum = prise[0] * m;
        int maxSum = sum;
        for(int i = 1;i < m;i++){
            sum = prise[i] * (m-i);
            if(sum > maxSum){
                maxSum = sum;
                max = prise[i];
            }
        }
        System.out.println(max);
    }
}
